package com.xjl.shujujiegou;

import com.xjl.firstpage.Test;

import java.util.Stack;


/**
 * @描述：
 * @作者： 许JIAN林
 */
public class UseTest {

    //1.测试用固定数组实现栈
    public static void TestArrStack() throws Exception {
        ArrStack arrStack = new ArrStack(5);
        for (int i = 0; i < 5; i++){
            arrStack.push(i);
        }
        for (int i = 0; i < 5; i++){
            System.out.println("显示栈顶元素：" + arrStack.peek());
        }
        for (int i = 0; i < 5; i++){
            System.out.println("出栈：" + arrStack.pop());
        }
    }
    //2.测试用固定数组实现队列
    public static void TestArrQueue() throws Exception {
        ArrQueue arrQueue = new ArrQueue(5);

        for (int i = 0; i < 5; i++){
            arrQueue.push(i);
        }
        for (int i = 0; i < 5; i++){
            System.out.println("显示栈顶元素：" + arrQueue.peek());
        }
        for (int i = 0; i < 5; i++){
            System.out.println("出栈：" + arrQueue.pop());
        }
    }

    //3.测试是否能实现特殊栈
    public static void TestSpecialStack() throws Exception {
        SpecialStack specialStack = new SpecialStack();

        for (int i = 0; i < 5; i++) {
            specialStack.push(i);
        }
        System.out.println("当前栈内最小值为：" + specialStack.getMin() );

        for (int i = 0; i < 5; i++) {
            System.out.println("当前栈顶元素：" +  specialStack.peek() );

        }

        for (int i = 0; i < 5; i++) {
            System.out.println("出栈：" +   specialStack.pop() );

        }
    }
    //4.测试是否能用队列实现栈
    public static void TestQueueStack() throws Exception {
        QueueStack stack = new QueueStack();
        for (int i = 0; i < 5; i++){
            stack.push(i);
        }
        for (int i = 0; i < 5; i++){
            System.out.println("显示栈顶元素：" + stack.peek());
        }
        for (int i = 0; i < 5; i++){
            System.out.println("出栈：" + stack.pop());
        }

    }

    //5.测试是否能用栈实现队列
    public static void TestStackQueue() throws Exception {
        StackQueue queue = new StackQueue();
        for (int i = 0; i < 5; i++){
            queue.push(i);
        }
        for (int i = 0; i < 5; i++){
            System.out.println("显示队头元素：" + queue.peek());
        }
        for (int i = 0; i < 5; i++){
            System.out.println("出队列：" + queue.pop());
        }

    }

    public static void main(String[] args) throws Exception {
//        //测试用固定数组实现栈
//        TestArrStack();
        //测试用固定数组实现队列
//        TestArrQueue();

        //3.测试是否能实现特殊栈
//        TestSpecialStack();
        //4.测试是否能用队列实现栈
//        TestQueueStack();

        //5.测试是否能用栈实现队列
        TestStackQueue();
    }
}
